//2009/08/07 01:23:58
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

class StringTrain
{
public:
    string buildTrain(vector <string> cars)
    {
		string train(cars[0]);
		for(int i=1; i<cars.size(); i++)
		{
			for(int j=cars[i].size()-1; j>0; j--)
			{
				const char *a = train.c_str();
				const char *b = cars[i].c_str();
				if(j >= train.size()) continue;
				if(strncmp(&a[train.size() - j ], b, j) != 0) continue;
				train += &b[j];
				break;
			}
		}
		string res;
		for(int i=0; i<train.size(); i++)
		{
			if(train.find_last_of(train[i]) == i)
				res += train[i];
		}
		char s[100];
		sprintf(s, "%d %s", train.size(), res.c_str());
		return s;
	}
};
